import sys

from PySide2.QtCore import Qt
from PySide2.QtWidgets import (
    QApplication, 
    QCheckBox,
    QDial,
    QLabel,
    QMainWindow,
    QPushButton,
    QVBoxLayout,
    QWidget,
    )


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("My App")

        self.createWidgets()
        self.layoutWidgets()

    
    def createWidgets(self):
        self.label = QLabel("Hello")
        font = self.label.font()
        font.setPointSize(30)
        self.label.setFont(font)
        self.label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

        self.pushButton = QPushButton('PushButton')

        self.checkBox = QCheckBox('CheckBox')

        self.dial = QDial()
        self.dial.setRange(-10, 100)
        self.dial.setSingleStep(0.5)
        self.dial.valueChanged.connect(self.onValueChanged)
        self.dial.sliderMoved.connect(self.onSliderMoved)
        self.dial.sliderPressed.connect(self.onSliderPressed)
        self.dial.sliderReleased.connect(self.onSliderReleased)

    def layoutWidgets(self):
        vBoxLayout = QVBoxLayout()
        vBoxLayout.setContentsMargins(10, 10, 10, 10)
        
        vBoxLayout.addWidget(self.label)
        vBoxLayout.addWidget(self.pushButton)
        vBoxLayout.addWidget(self.checkBox)
        vBoxLayout.addWidget(self.dial)

        widget = QWidget()
        widget.setLayout(vBoxLayout)
        self.setCentralWidget(widget)

    def onValueChanged(self, value):
        print('onValueChanged', value)
    
    def onSliderMoved(self, position):
        print('onSliderMoved', position)

    def onSliderPressed(self):
        print('onSliderPressed')
    def onSliderReleased(self):
        print('onSliderReleased')


app = QApplication(sys.argv)
app.setStyle('Fusion')

window = MainWindow()
window.show()

app.exec_()